<extend name="Public/base" />


<{// 导航}>
<block name="breadcrumb">
<li class="active">友情链接列表</li>
</block>

<{// 左侧菜单}>
<block name="sidebar">
	<include file="Public/sidebar" nav="link"/>
</block>

<{// 主体}>
<block name="main">
<div class="row-fluid">
	<h3 class="header blue lighter smaller">
		<div class="row-fluid  dataTables_wrapper">
			<div class="span4">
				<button class="btn btn-primary btn-small" onclick="$.lagou.formShow('<{:U('Admin/Link/add')}>');" type="button"><i class="icon-plus"></i>添加友情连接</button>
			</div>
			<div class="span8" id="m_search_div"></div>	
		</div>
	</h3>
	<div class="table-header">友情链接列表</div>
	<table id="data_table" class="table table-striped table-bordered table-hover" style="margin-bottom:0px;">
		<thead>
			<tr>
				<th>id</th>
				<th>名称</th>
				<th>URL</th>
				<th>创建时间</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody>
			<?php foreach ($data as $key => $value): ?>
                        <tr>
                            <td><{$value.id}></td>
					        <td><{$value.title}></td>
					        <td><a href="<{$value.url}>" target="_blank"><{$value.url}></a></td>
					        <td><{$value.create_time|date="Y-m-d H:i", ###}></td>
					<td>
						<div class="hidden-phone visible-desktop action-buttons">
							<a href="javascript:;" onclick="$.lagou.formShow('<{:U('Admin/Link/edit', array('id'=>$value['id']))}>');" class="blue tooltip-info no-hover-underline" data-rel="tooltip" data-original-title="编辑资料">
								<i class="icon-pencil bigger-130"></i>
							</a>
							<a href="javascript:;" onclick="$.del('<{:U('Admin/Link/delete', array('id'=>$value['id']))}>');" class="red tooltip-error no-hover-underline" data-rel="tooltip" data-original-title="删除连接"><i class="icon-trash bigger-130"></i></a>
						</div>
					</td>
				</tr>
			<?php endforeach ?>
		</tbody>
	</table>
	<!-- 分页 -->
	<div class="row-fluid">
		<div class="page"><{$page}></div>
	</div>
</div>
</block>

<{// js}>
<block name="js">
	<script type="text/javascript">
			jQuery(function($) {

				// 这就是全选按钮
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});	
				});
				
				$.extend({

					del : function(url)
					{
						$.lagou.confirm('确认删除么', function(res){
							if (res) {
								$.get(url, function(response){
									$.lagou.alert(response.msg, response.code, 2);
									location.reload(0);
								});
							}
						});
					}
				});
			})
		</script>
</block>